package com.java.zhuiyun.api.series_course.controller;

import com.java.zhuiyun.api.back_course.entity.BackCourse;
import com.java.zhuiyun.api.series_course.entity.SeriesCourse;
import com.java.zhuiyun.api.series_course.model.SeriesCourseModel;
import com.java.zhuiyun.api.series_course.service.SeriesCourseService;
import com.java.zhuiyun.common.response.CommonResult;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import com.java.zhuiyun.util.pageUtil.PageResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName BackSeriesCourseController
 * @Description TODO
 * @Author 杨友朋
 * @Date 2023/8/30 11:33
 **/
@RestController
@RequestMapping("/backSeriesCourse")
@CrossOrigin
public class BackSeriesCourseController {
    @Resource
    SeriesCourseService seriesCourseService;

    @PostMapping("/insertSeries")
    public CommonResult insertSeries(MultipartFile file, SeriesCourseModel seriesCourse) {
        return seriesCourseService.insertSeries(file, seriesCourse);
    }
    @PostMapping("/upSeries")
    public CommonResult upSeries(MultipartFile file, SeriesCourseModel seriesCourse) {
        return seriesCourseService.upSeries(file, seriesCourse);
    }

    @GetMapping("/selectSeries")
    public CommonResult selectSeries(SeriesCourseModel seriesCourseModel, PageRequest pageResult) {
        return CommonResult.ok(seriesCourseService.selectSeries(seriesCourseModel, pageResult));
    }

    @GetMapping("/teacherSelectSeries")
    public CommonResult teacherSelectSeries(SeriesCourseModel seriesCourseModel, PageRequest pageResult) {
        return CommonResult.ok(seriesCourseService.teacherSelectSeries(seriesCourseModel, pageResult));
    }
    @GetMapping("/selectDict")
    public CommonResult selectDict(Integer teacherId) {
        return CommonResult.ok(seriesCourseService.selectCourse(teacherId));
    }

    @GetMapping("/selectCheck")
    public CommonResult selectCheck(Integer id){
        return seriesCourseService.selectCheck(id);
    }
    @PostMapping("addCourse")
    public CommonResult addCourse(@RequestBody SeriesCourseModel seriesCourse){
        System.out.println(seriesCourse);

        return seriesCourseService.addCourse(seriesCourse);
    }
    @GetMapping("/delCourse")
    public CommonResult delCourse(Integer id){
        return seriesCourseService.delCourse(id);
    }
    @GetMapping("/selectById")
    public CommonResult selectById(Integer id){
        return seriesCourseService.selectById(id);
    }

    @GetMapping("/upSwitch")
    public CommonResult upSwitch(SeriesCourse seriesCourse){
        return seriesCourseService.upSwitch(seriesCourse);
    }
}
